<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_Markup Renderers - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.markup.renderers.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.markup.renderers.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.markup.parsers.html">Zend_Markup Parsers</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.markup.html">Zend_Markup</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.measure.html">Zend_Measure</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.markup.renderers" class="section"><div class="info"><h1 class="title">Zend_Markup Renderers</h1></div>
    

    <p class="para">
        <span class="classname">Zend_Markup</span> is currently shipped with one renderer, the
        <acronym class="acronym">HTML</acronym> renderer.
    </p>

    <div class="section" id="zend.markup.renderers.add"><div class="info"><h1 class="title">Adding your own markups</h1></div>
        

        <p class="para">
            By adding your own markups, you can add your own functionality to the
            <span class="classname">Zend_Markup</span> renderers. With the markup structure, you can add
            about any functionality you want. From simple markups, to complicated markup structures.
            A simple example for a &#039;foo&#039; markup:
        </p>

        <pre class="programlisting brush: php">
// Creates instance of Zend_Markup_Renderer_Html,
// with Zend_Markup_Parser_BbCode as its parser
$bbcode = Zend_Markup::factory(&#039;Bbcode&#039;);

// this will create a simple &#039;foo&#039; markup
// The first parameter defines the markup&#039;s name.
// The second parameter takes an integer that defines the markups type.
// The third parameter is an array that defines other things about a
// markup, like the markup&#039;s group, and (in this case) a start and end markup.
$bbcode-&gt;addMarkup(
    &#039;foo&#039;,
    Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE,
    array(
        &#039;start&#039; =&gt; &#039;-bar-&#039;,
        &#039;end&#039;   =&gt; &#039;-baz-&#039;,
        &#039;group&#039; =&gt; &#039;inline&#039;
    )
);

// now, this will output: &#039;my -bar-markup-baz-&#039;
echo $bbcode-&gt;render(&#039;my [foo]markup[/foo]&#039;);
</pre>


        <p class="para">
            Please note that creating your own markups only makes sense when your parser also
            supports it with a markup structure. Currently, only BBCode supports this. Textile
            doesn&#039;t have support for custom markups.
        </p>

        <p class="para">
            Some renderers (like the <acronym class="acronym">HTML</acronym> renderer) also have support for a
            &#039;markup&#039; parameter. This replaces the &#039;start&#039; and &#039;end&#039; parameters, and
            it renders the markups including some default attributes and the
            closing markup.
        </p>

        <div class="section" id="zend.markup.renderers.add.callback"><div class="info"><h1 class="title">Add a callback markup</h1></div>
            

            <p class="para">
                By adding a callback markup, you can do a lot more then just a
                simple replace of the markups. For instance, you can change the
                contents, use the parameters to influence the output etc.
            </p>

            <p class="para">
                A callback is a class that implements the
                <span class="classname">Zend_Markup_Renderer_TokenInterface</span>
                interface. An example of a callback class:
            </p>

            <pre class="programlisting brush: php">
class My_Markup_Renderer_Html_Upper
    implements Zend_Markup_Renderer_TokenConverterInterface
{

    public function convert(Zend_Markup_Token $token, $text)
    {
        return &#039;!up!&#039; . strtoupper($text) . &#039;!up!&#039;;
    }

}
</pre>


            <p class="para">
                Now you can add the &#039;upper&#039; markup, with as callback, an instance
                of the <span class="classname">My_Markup_Renderer_Html_Upper</span>
                class. A simple example:
            </p>

            <pre class="programlisting brush: php">
// Creates instance of Zend_Markup_Renderer_Html,
// with Zend_Markup_Parser_BbCode as its parser
$bbcode = Zend_Markup::factory(&#039;Bbcode&#039;);

// this will create a simple &#039;foo&#039; markup
// The first parameter defines the markup&#039;s name.
// The second parameter takes an integer that defines the markups type.
// The third parameter is an array that defines other things about a
// markup, like the markup&#039;s group, and (in this case) a start and end markup.
$bbcode-&gt;addMarkup(
    &#039;upper&#039;,
    Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE,
    array(
        &#039;callback&#039; =&gt; new My_Markup_Renderer_Html_Upper(),
        &#039;group&#039;    =&gt; &#039;inline&#039;
    )
);

// now, this will output: &#039;my !up!MARKUP!up!&#039;
echo $bbcode-&gt;render(&#039;my [upper]markup[/upper]&#039;);
</pre>

        </div>
    </div>

    <div class="section" id="zend.markup.renderers.list"><div class="info"><h1 class="title">List of markups</h1></div>
        

        <table id="zend.markup.renderers.list.markups" class="doctable table"><div class="info"><caption><b>List of markups</b></caption></div>
            

            
                <thead valign="middle">
                    <tr valign="middle">
                        <th>Sample input (bbcode)</th>
                        <th>Sample output</th>
                    </tr>

                </thead>


                <tbody valign="middle" class="tbody">
                    <tr valign="middle">
                        <td align="left">[b]foo[/b]</td>
                        <td align="left">&lt;strong&gt;foo&lt;/strong&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[i]foo[/i]</td>
                        <td align="left">&lt;em&gt;foo&lt;/em&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[cite]foo[/cite]</td>
                        <td align="left">&lt;cite&gt;foo&lt;/cite&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[del]foo[/del]</td>
                        <td align="left">&lt;del&gt;foo&lt;/del&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[ins]foo[/ins]</td>
                        <td align="left">&lt;ins&gt;foo&lt;/ins&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[sup]foo[/sup]</td>
                        <td align="left">&lt;sup&gt;foo&lt;/sup&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[sub]foo[/sub]</td>
                        <td align="left">&lt;sub&gt;foo&lt;/sub&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[span]foo[/span]</td>
                        <td align="left">&lt;span&gt;foo&lt;/span&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[acronym title=&quot;PHP Hypertext Preprocessor]PHP[/acronym]</td>

                        <td align="left">
                            &lt;acronym title=&quot;PHP Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt;
                        </td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[url=http://framework.zend.com/]Zend Framework[/url]</td>

                        <td align="left">
                            &lt;a href=&quot;http://framework.zend.com/&quot;&gt;Zend Framework&lt;/a&gt;
                        </td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[h1]foobar[/h1]</td>
                        <td align="left">&lt;h1&gt;foobar&lt;/h1&gt;</td>
                    </tr>


                    <tr valign="middle">
                        <td align="left">[img]http://framework.zend.com/images/logo.gif[/img]</td>

                        <td align="left">
                            &lt;img src=&quot;http://framework.zend.com/images/logo.gif&quot; /&gt;
                        </td>
                    </tr>

                </tbody>
            
        </table>

    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.markup.parsers.html">Zend_Markup Parsers</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.markup.html">Zend_Markup</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.measure.html">Zend_Measure</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.markup.html">Zend_Markup</a></li>
  <li><a href="zend.markup.introduction.html">Introduction</a></li>
  <li><a href="zend.markup.getting-started.html">Getting Started With Zend_Markup</a></li>
  <li><a href="zend.markup.parsers.html">Zend_Markup Parsers</a></li>
  <li class="active"><a href="zend.markup.renderers.html">Zend_Markup Renderers</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>